<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<link th:href="@{/assets/css/bootstrap.min.css}" rel="stylesheet" />
<link rel="stylesheet" th:href="@{/assets/fileinput/css/fileinput.min.css}" />
<link rel="stylesheet" th:href="@{/assets/fileinput/themes/explorer/theme.min.css}" />
<link rel="stylesheet" th:href="@{/assets/css/font-awesome.min.css}" />
<link rel="stylesheet" th:href="@{/assets/css/font-awesome-ie7.min.css}" />
<link rel="stylesheet" th:href="@{/assets/css/jquery-ui-1.10.3.custom.min.css}" />
<link rel="stylesheet" th:href="@{/assets/css/colorbox.css}" />
<link th:href="@{/assets/css/ace.min.css}" rel="stylesheet" type="text/css"/>
<link th:href="@{/assets/css/ace-rtl.min.css}" rel="stylesheet" type="text/css"/>
<link th:href="@{/assets/css/ace-skins.min.css}" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" th:href="@{/My97DatePicker/skin/WdatePicker.css}"/>
<head th:include="fragments/head::header" />
<body>
<div th:include="fragments/top::top"></div>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <div th:include="fragments/left::left" class="sidebar" id="sidebar"></div>
        <div class="main-content">
            <!--<div class="breadcrumbs" id="breadcrumbs">-->
                <!--<ul class="breadcrumb">-->
                    <!--<li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>-->
                    <!--<li>后续申请结果</li>-->
                    <!--<li id="bread_show">查看</li>-->
                    <!--<li id="bread_update">修改</li>-->
                <!--</ul>-->
            <!--</div>-->
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-xs-12">
                                <h3 class="header smaller lighter blue">申请结果信息</h3>
                                <br/>
                                <input id="type" th:value="${type}" type="text" name="stuNo" style="display: none"/>
                                <input id="id" th:value="${date}" type="text" name="stuNo" style="display: none"/>
                                <input id="canApprove" th:value="${canApprove}" type="text"  style="display: none"/>
                                <input id="applyId" th:value="${applyId}" type="text" name="stu_id" style="display: none"/>
                                <input id="studentNo" th:value="${studentNo}" type="text" name="stu_id" style="display: none"/>
                                <input id="offerAttachment" th:value ="${followServiceResult.offerAttachment}" style="display: none"/>
                                <input id="auditStatus" th:value="${followServiceResult.auditStatus !=null} ? ${followServiceResult.auditStatus}" type="text" name="auditStatus" style="display: none"/>
                                <input id = "input_fileName" th:value="${followServiceResult!=null}? ${followServiceResult.offerAttachment}" style="display: none"/>
                                <input id = "resultType" th:value="${followServiceResult!=null}? ${followServiceResult.resultType}" style="display: none"/>
                                <input id = "updateTime" th:value="${followServiceResult.updateTime!=null}? ${#dates.format(followServiceResult.updateTime,'yyyy-MM-dd HH:mm:ss')}" style="display: none"/>
                                <input id="resDomain" th:value ="${resDomain}" style="display: none"/>
                                <div  class="tab-pane fade in active">
                                    <div class="container">
                                        <div class="form-horizontal">
                                            <div class="form-group" style="height:32px">
                                                <label class="col-sm-3 control-label no-padding-right"> 申请结果：</label>
                                                    <select type="" class="col-sm-3 form-control input-sm" id="application_result" style="width:190px;height:25px;" disabled="disabled">
                                                        <option value="1" th:selected="${followServiceResult.resultType==1}">录取</option>
                                                        <option value="2" th:selected="${followServiceResult.resultType==2}">拒绝</option>
                                                        <option value="0" th:selected="${followServiceResult.resultType == null}">请选择</option>
                                                    </select>
                                                <label class="col-sm-3 control-label no-padding-right"> 申请结果到达方式：</label>
                                                <select type="" class="col-sm-3 form-control input-sm" id="application_result_reply_way" style="width:190px;height:25px;" disabled="disabled">
                                                    <option value="1" th:selected="${followServiceResult.replyWay == 1}">传真</option>
                                                    <option value="2" th:selected="${followServiceResult.replyWay == 2}">电话</option>
                                                    <option value="3" th:selected="${followServiceResult.replyWay == 3}">电子版</option>
                                                    <option value="4" th:selected="${followServiceResult.replyWay == 4}">扫描件</option>
                                                    <option value="5" th:selected="${followServiceResult.replyWay == 5}">原件</option>
                                                    <option value="0" th:selected="${followServiceResult.replyWay == null}">请选择</option>
                                                </select>
                                            </div>
                                            <div class="form-group offer_info" style="height:32px">
                                                <label class="col-sm-3 control-label no-padding-right"> 申请结果到达日期：</label>
                                                <input id="application_result_date" class="Wdate col-sm-3" style="width: 190px" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                                                       th:value="${followServiceResult.resultDate != null}? ${#dates.format(followServiceResult.resultDate, 'yyyy-MM-dd HH:mm:ss')}"/>
                                                <!--<label class="col-sm-3 control-label no-padding-right"> 接受offer截止日期：</label>-->
                                                <!--<input id="application_result_dateline" class="Wdate col-sm-3" style="width: 190px" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"-->
                                                       <!--th:value="${followServiceResult.replyDeadline != null}? ${#dates.format(followServiceResult.replyDeadline, 'yyyy-MM-dd HH:mm:ss')}"/>-->
                                            </div>
                                            <div class="form-group reply_reason" style="height:32px">
                                                <label class="col-sm-3 control-label no-padding-right"> 申请结果到达日期：</label>
                                                <input id="application_result_date_refuse" class="Wdate col-sm-3" style="width: 190px" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                                                       th:value="${followServiceResult.resultDate != null}? ${#dates.format(followServiceResult.resultDate, 'yyyy-MM-dd HH:mm:ss')}"/>
                                                <label class="col-sm-3 control-label no-padding-right"> 拒绝原因：</label>
                                                <input id = "reply_reason_id" class = " col-sm-3" th:value="${followServiceResult.replyReason != null} ? ${followServiceResult.replyReason}"  style="width: 190px" />
                                            </div>
                                            <!--<div class="form-group studetn_info" style="height:32px">-->
                                                <!--<label class="col-sm-3 control-label no-padding-right"> 学生确认offer回复日期：</label>-->
                                                <!--<input id="application_student_reply_date" class="Wdate col-sm-3" style="width: 190px"  th:value="${followServiceResult.studentReplyDate != null} ? ${#dates.format(followServiceResult.studentReplyDate, 'yyyy-MM-dd HH:mm:ss')}"  readOnly="true"/>-->
                                                <!--<label class="col-sm-3 control-label no-padding-right"> 学校确认offer日期：</label>-->
                                                <!--<input id="application_school_reply_date" class="Wdate col-sm-3" style="width: 190px" th:value="${followServiceResult.schoolReplyDate != null} ? ${#dates.format(followServiceResult.schoolReplyDate, 'yyyy-MM-dd HH:mm:ss')}" readOnly="true"/>-->
                                            <!--</div>-->
                                            <!--<div class="form-group school_info" style="height:32px">-->
                                                <!--<label class="col-sm-3 control-label no-padding-right"> 实际接受offer回复日期：</label>-->
                                                <!--<input id="application_argue_date" class="Wdate col-sm-3" style="width: 190px"  th:value="${followServiceResult.createTime != null} ? ${#dates.format(followServiceResult.createTime, 'yyyy-MM-dd HH:mm:ss')}" readOnly="true" />-->
                                            <!--</div>-->
                                            <div class="form-group " style="height:230px" id="upload_offer">
                                                <label class="col-sm-3 control-label no-padding-right"> offer扫描件：</label>
                                                <form method="post" action="/upload" id="form_file" enctype="multipart/form-data" >
                                                    <div  class="tab-pane fade in active">
                                                        <div class="container">
                                                            <div class="form-horizontal">
                                                                <div class="form-group">
                                                                    <div class="col-sm-6" style="padding-left: 0px;" >
                                                                        <div class="widget-header">
                                                                            <h4>文件上传</h4>
                                                                        </div>
                                                                        <div class="widget-body">
                                                                            <div class="widget-main">
                                                                                <span id = "offer_attachment" style="display: none"><span id = "offerAttachment_show" th:text="${followServiceResult.offerAttachment != null} ? ${followServiceResult.offerAttachment}"></span><span class="btn btn-sm btn-primary _visa_file" th:value="${followServiceResult.offerAttachment != null} ? ${followServiceResult.offerAttachment}" style="left:9%" id = "">预览</span><a th:href="${followServiceResult.offerAttachment} ? ${followServiceResult.offerAttachment}" download="offer信息下载" id="upload_office"><span class="btn btn-sm btn-primary" style="left:15%" id = "offer_upload">下载</span></a></span>
                                                                                <input name ="fileInput"  type="file" id="id-input-file-3" />
                                                                                <label>
                                                                                    <input type="checkbox" name="file-format" id="id-file-format" class="ace" />
                                                                                </label>
                                                                                <span style="color: #FF2F2F">*上传文件的格式为&nbsp;:&nbsp;&nbsp; .jpg，&nbsp;.png，&nbsp;.gif,&nbsp;.doc，&nbsp;.docx，&nbsp;.pdf，&nbsp;.eml</span>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                            <div class="form-group" style="height:32px">
                                                <label class="col-sm-3 control-label no-padding-right"> 备注：</label>
                                                <div class="col-sm-3" style="padding-left: 0px;">
                                                    <textarea rows="5" cols="76" name="comment" id="textarea_comment" th:text="${followServiceResult!=null}? ${followServiceResult.resultComment}" disabled="disabled"></textarea>
                                                </div>
                                            </div>
                                            <input id="auditApply" th:value="${auditSysUser}" style="display: none"/>
                                            <div class="form-group"    style="margin-top: 76px; margin-left: 85px;display: none;" id="audit_button">
                                                <label class="col-sm-3 control-label no-padding-right blue">
                                                    <div th:each="applyInfo:${auditSysUsers}" style="float:left;">
                                                    <span  th:text="'待审批人OA：'+${applyInfo.oaid + '-' +  applyInfo.username}"></span>
                                                    </div>
                                                </label>
                                            </div>
                                            <!-- 审批内容 -->
                                            <div class="form-group" style="margin-top: 40px;" th:unless="${#lists.isEmpty(list_case_8)}">
                                                <input id="show_audit" value="1" style="display: none"/>
                                                <table class="table" width="450" border="1" cellspacing="4" style="margin-top: 50px"
                                                       cellpadding="1">
                                                    <tr>
                                                        <td align="center">审批结果</td>
                                                        <td align="center">审批人</td>
                                                        <td align="center">审批时间</td>
                                                        <td align="center">审批意见</td>
                                                    </tr>
                                                    <tr th:each="item,iterStat:${list_case_8}">
                                                        <td style="text-align: center; vertical-align: middle;" th:text="${item.applyStatus_string}"></td>
                                                        <td style="text-align: center; vertical-align: middle;" th:text="${item.operatorName}"></td>
                                                        <td style="text-align: center; vertical-align: middle;" th:text="${#dates.format(item.createTime, 'yyyy-MM-dd')}"></td>
                                                        <td style="text-align: center; vertical-align: middle;" th:text="${item.reason}"></td>
                                                    </tr>
                                                </table>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" id="btn_return">返回</button>
                <button type="button" class="btn btn-primary" id="btn_save">保存</button>
                <button type="button" class="btn btn-primary" id="btn_approval" onclick="approve()" style="display: none" >审批</button>
            </div>

        </div>
    </div>
</div>

<div th:include="fragments/js::js"></div>
<!-- page specific plugin scripts -->

<script th:src="@{/business/followService/followService.js}" charset="UTF-8"></script>
<script th:src="@{/My97DatePicker/WdatePicker.js}"></script>
<script th:src="@{/assets/js/jquery.inputlimiter.1.3.1.min.js}"></script>
<script th:src="@{/assets/js/jquery.maskedinput.min.js}"></script>
<script th:src="@{/assets/js/bootstrap-tag.min.js}"></script>
<script th:src="@{/assets/js/ace-elements.min.js}"></script>
<script th:src="@{/assets/js/ace.min.js}"></script>
<script th:src="@{/assets/js/jquery.form.js}"></script>
<script th:src="@{/business/common.js}"></script>
<script th:src="@{/layer/layer.js}"></script>
<script th:src="@{/js/upload/upload.js}"></script>
<script th:inline="javascript">
    /*<![CDATA[*/
    var data_offer = [[${followServiceResult.offerAttachment}]];

    var uploadResult = true;
$(function(){
    if($("#type").val()==1){
        if($("#canApprove").val()){
            $("#btn_approval").show();
        }
    }

    if($("#type").val()==1) {
        if ($("#auditApply").val() == "true") {
            $("#audit_button").show();
        }
    }
})
    $("#offerAttachment_show").text(data_offer.substring(0,50)+"...");

    $("#offer_show").click(function(){
        if($("#offerAttachment").val().indexOf($("#resDomain").val()) ==-1){
            window.open($("#resDomain").val()+$("#offerAttachment").val());
        }else{
            window.open($("#offerAttachment").val());
        }
    })

    $("#offer_upload").click(function(){
        if($("#offerAttachment").val().indexOf($("#resDomain").val()) ==-1){
            $("#upload_office").attr("href",$("#resDomain").val()+$("#offerAttachment").val());
        }else{
            $("#upload_office").attr("href",$("#offerAttachment").val());
        }

    })

$(function(){
      //1查看  2修改
        var type = $("#type").val();

        if(type == "1" ){
            $("#btn_save").hide();
            $("#btn_return").show();
        }else if(type == '2'){
            $("#btn_return").show();
            $("#btn_save").show();
            $("#textarea_comment").removeAttr("disabled");
        }

        if(type == "1" ){
            if(data_offer != ''){
                $("#upload_offer").attr("style","height:270px");
                $("#offer_attachment").show();
                $("input").attr("disabled", "disabled");
                upLoadImg()
            }else{
                $("input").attr("disabled", "disabled");
                upLoadImg();
            }
        }else if(type == "2"){

            if(data_offer != ''){
                $("#upload_offer").attr("style","height:270px");
                $("#offer_attachment").show();
                upLoadImg();
            }else{
                upLoadImg();
            }

        }
        $("#btn_save").click(function(){
            if(uploadResult == false){
                layer.msg('正在上传中,请稍后保存!');
            }else{
                postData(2);
            }

        });
        $("#btn_return").click(function () {
            postData(1);
        });
})
    $("#btn_file_submit").click(function(){
        $("#form_file").submit();
    });
    var country = "meiguo";

    //审批
    function approve(){
        console.log("修改时间:"+$("#updateTime").val());
        //var applyId = $("#applyId").val();
        var id = $("#id").val();
        layer.prompt({
            formType: 2,
            title: '请添加备注',
            btn: ['通过', '拒绝'],
            yes: function (index, layero) {
                var loadIndex = layer.load(1, {shade: [0.5, '#393D49']});
                var reason = layero.find('.layui-layer-input').val();
                $.ajax({
                    url: "/followService/approve",
                    type: "post",
                    data: {
                        applyId: id,
                        type: 2,
                        remark: reason,
                        studentNo:$("#studentNo").val(),
                        updateTime:$("#updateTime").val()
                    },
                    success: function (data) {
                        layer.close(loadIndex);
                        layer.close(index);
                        if (data.result) {
                            layer.msg(data.errorMsg, {time: 1000});
                            window.location.reload();
                        } else if(data.errorCode == "2"){
                            parent.layer.confirm('需审批内容已修改,请重新审批', {
                                icon: 7,
                                btn: ['确定']
                            },function(){
                                window.location.replace(window.location.href)
                            });
                        }else if(data.errorCode == "1"){
                            layer.msg(data.errorMsg, {time: 1000});
                            window.location.reload();
                        }
                    }
                })
            },
            btn2: function (index, layero) {
                var loadIndex = layer.load(1, {shade: [0.5, '#393D49']});
                var reason = layero.find('.layui-layer-input').val();
                $.ajax({
                    url: "/followService/approve",
                    type: "post",
                    data: {
                        applyId: id,
                        type: 1,
                        remark: reason,
                        studentNo:$("#studentNo").val(),
                        updateTime:$("#updateTime").val()
                    },
                    success: function (data) {
                        layer.close(loadIndex);
                        console.log("后台返回:"+data);
                        if (data.result) {
                            layer.msg(data.errorMsg, {time: 1000});
                            window.location.reload();
                        } else if(data.errorCode == "2"){
                            parent.layer.confirm('需审批内容已修改,请重新审批', {
                                icon: 1,
                                btn: ['确定']
                            },function(){
                                window.location.replace(window.location.href)
                            });
                        }else if(data.errorCode == "1"){
                            layer.msg(data.errorMsg, {time: 1000});
                            window.location.reload();
                        }
                    }
                })
            }
        })
    }

    function upLoadImg(){
        $('#id-input-file-3').ace_file_input({
            style:'well',
            btn_choose:'Drop files here or click to choose',
            btn_change:null,
            no_icon:'icon-cloud-upload',
            droppable:true,
            thumbnail:'small',//large | fit
            before_change:function(files, dropped) {
                return true;
            },
            before_remove : function() {
                $("#upload_offer").attr("style","height:270px");
                $("#offerAttachment").val(data_offer);
                $("#input_fileName").val(data_offer);
                return true;
            },
            preview_error : function(filename, error_code) {
            }
        }).on('change', function(){
            //获取文件大小
            if (!checkUp(this)) {
                return false;
            }
            uploadResult = false;
            layer.msg('正在上传中...', {
                icon: 16
                ,shade: 0.01
            });
            $("#form_file").ajaxSubmit(function(message) {
                uploadResult = true;
                console.log(message);
                var fileName = message.obj;
                var code = message.code;
                if(code == "1"){
                    layer.msg("请上传正确的文件格式!")
                }else if(message.success){
                    $("#upload_offer").attr("style", "height:200px");
                    $("#input_fileName").val(fileName);
                    $("#offerAttachment").val(fileName);
                    layer.msg("上传成功!");
                }
            });
        });
    }
/*]]>*/
</script>
</body>
</html>
